# 生成日期列表
import datetime
def date_range(begin_date,end_date):
    dates = []
    if '-' in begin_date:
        dt = datetime.datetime.strptime(begin_date, '%Y-%m-%d')
        date = begin_date
        while date <= end_date:
            dates.append(date)
            dt = dt + datetime.timedelta(1)
            date = dt.strftime('%Y-%m-%d')
        return dates
    else:
        dt = datetime.datetime.strptime(begin_date, '%Y%m%d')
        date = begin_date
        while date <= end_date:
            dates.append(date)
            dt = dt + datetime.timedelta(1)
            date = dt.strftime('%Y%m%d')
        return dates

print(date_range('2020-09-20','2020-09-24'))